package com.ruoyi.system.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dyun.tool.mybatis.domain.PageDomain;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ruoyi.common.annotation.SysLog;
import com.ruoyi.common.enums.BusinessTypeEnum;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.project.system.entity.SysTenant;
import com.ruoyi.project.system.service.SysTenantService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.properties.IntegerProperty;
import lombok.AllArgsConstructor;
import net.dreamlu.mica.core.result.R;
import net.dreamlu.mica.core.validation.CreateGroup;
import net.dreamlu.mica.core.validation.UpdateGroup;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 系统租户  控制层
 *
 * @author dyun
 */
@RestController
@RequestMapping("system/tenant")
@AllArgsConstructor
public class SysTenantController extends BaseController {

    private final SysTenantService sysTenantService;

    /**
     * 分页
     */
    @PreAuthorize("@ss.hasPermi('system:tenant:list')")
    @GetMapping("/list")
    public R<IPage<SysTenant>> list(SysTenant sysTenant, PageDomain pageDomain) {
        IPage<SysTenant> pages = sysTenantService.page(startPage(pageDomain), new LambdaQueryWrapper<SysTenant>());
        return success(pages);
    }

    /**
     * 详情
     */
    @PreAuthorize("@ss.hasPermi('system:tenant:query')")
    @GetMapping("/detail")
    public R<SysTenant> detail(Long id) {
        return success(sysTenantService.getById(id));
    }

    /**
     * 修改
     */
    @PreAuthorize("@ss.hasPermi('system:tenant:edit')")
    @PutMapping("/update")
    public R update(@Validated(value = {UpdateGroup.class}) @RequestBody SysTenant sysTenant) {
        return status(sysTenantService.updateById(sysTenant));
    }
}